import axios from 'axios'
import baseService from './request'
import { Message } from 'element-ui'

const service = axios.create({
  baseURL: process.env.VUE_APP_BASE_API, // api 的 VUE_APP_BASE_API
  timeout: 12000, // request timeout
  responseType: 'blob'
})

service.interceptors.request = baseService.interceptors.request
// 响应拦截器
service.interceptors.response.use(res => {
    return res
  },
  error => {
    console.log('err' + error)
    Message({
      message: error.message,
      type: 'error',
      duration: 5 * 1000
    })
    return Promise.reject(error)
  }
)

export default service
